from django.db import models

# Create your models here.

# 映射  app_user
class User(models.Model):
    id = models.AutoField(primary_key=True)
    username = models.CharField(max_length=15)
    password = models.CharField(max_length=20)


class Press(models.Model):
    id = models.AutoField(primary_key=True)
    pressname = models.CharField(max_length=50)
    pressaddress = models.CharField(max_length=50)

class Book(models.Model):
    id = models.AutoField(primary_key=True)
    bookname = models.CharField(max_length=50)
    bookprice = models.DecimalField(max_digits=10,decimal_places=2)
    bookauthor = models.CharField(max_length=30)
    bookimg = models.CharField(max_length=255)
    press = models.ForeignKey(to="Press",on_delete=models.SET_NULL,null=True, blank=True)

class Booktype(models.Model):
    id = models.AutoField(primary_key=True)
    typename = models.CharField(max_length=50)
    books = models.ManyToManyField(to="Book")


# class Booktypet_Book(models.Model):
#     id = models.AutoField(primary_key=True)
#     booktype=models.ForeignKey(to="Booktype",on_delete=models.CASCADE)
#     book=models.ForeignKey(to="Book",on_delete=models.CASCADE)



